#include <bits/stdc++.h>
using namespace std;

int q, n, a[1001];
bool b[10001];
int cnt = 0;

int main() {
    cin >> q;
    for(; q--; ) {
        cin >> n;
        cnt = 0;
        for(int i = 1; i <= n; i ++) {
            cin >> a[i];
            if(a[i] % 2) b[i] = true;
            else b[i] = false;
        }
        //cout << n << " " << flag << endl;
        if(n == 1) 
            cout << 0 << endl;
        else {
            for(int i = 2; i <= n; i++) {
                if(b[i] == b[i - 1]) cnt ++;
            }
            cout << cnt << endl;
        }
    }
}